#include "qdatamanager.h"

QDataManager *QDataManager::m_manager=NULL;

QDataManager::QDataManager(QObject *parent) :
    QObject(parent)
{
}

void QDataManager::setUserData(const QString &key, const QVariant &value)
{
    QVariant v=m_userData.value(key,QVariant());
    if(v!=value)
    {
        m_userData.insert(key,value);
        emit userDataChanged(key,value);
    }
}

QVariant QDataManager::userData(const QString &key, const QVariant &def)
{
    if(m_userData.contains(key))
    {
        return m_userData.value(key,def);
    }
    else
    {
        return QVariant();
    }
}

QDataManager* QDataManager::manager()
{
    if(m_manager==NULL)
    {
        m_manager=new QDataManager;
    }
    return m_manager;
}

void QDataManager::releaseManager()
{
    if(m_manager!=NULL)
    {
        delete m_manager;
        m_manager=NULL;
    }
}

